<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:c="http://java.sun.com/jsp/jstl/core">


<ui:composition template="/WEB-INF/templates/BasicTemplate.xhtml">
	<c:set target="#{flash}" property="keepMessages" value="false"/>
	<ui:define name="content">
		<h:form id="addBook" >
			<h:panelGrid columns="3">
				<h:outputLabel for="isbn">ISBN</h:outputLabel>
				<h:inputText id="isbn" value="#{bookBean.book.isbn}" required="true" requiredMessage="Please insert ISBN" >
					<f:validator validatorId="isbnValidator"/>
				</h:inputText>
				<h:message for="isbn" style="color:red;"/>
				
				<h:outputLabel for="author">Autor</h:outputLabel>
				<h:inputText id="author" value="#{bookBean.book.author}" required="true" requiredMessage="Please insert author" />
				<h:message for="author" style="color:red;"/>

				<h:outputLabel for="title">Tytuł</h:outputLabel>
				<h:inputText id="title" value="#{bookBean.book.title}" required="true" requiredMessage="Please insert title" />
				<h:message for="title" style="color:red;"/>

				<h:outputLabel for="publisher">Wydawnictwo</h:outputLabel>
				<h:inputText id="publisher" value="#{bookBean.book.publisher}"
					required="true"  requiredMessage="Please insert publisher"/>
				<h:message for="publisher" style="color:red;"/>

				<h:outputLabel for="publicationYear">Rok Wydania</h:outputLabel>
				<h:inputText id="publicationYear"
					value="#{bookBean.book.publicationYear}" required="true"
					validatorMessage="Year must be between 1900 and 2012"
					requiredMessage="Please insert publication year">
					<f:validateLongRange minimum="1900" maximum="2012" />
				</h:inputText>
				<h:message for="publicationYear" style="color:red;"/>
				


				<h:outputLabel for="list">Kategorie</h:outputLabel>
				<h:selectManyCheckbox id="list" layout="pageDirection" selectedValues="#{bookBean.categoryList}" required="true" requiredMessage="Please select category">
					<f:selectItem itemLabel=" Dramat" itemValue="Dramat" />
					<f:selectItem itemLabel=" Fantasy" itemValue="Fantasy" />
					<f:selectItem itemLabel=" Horror" itemValue="Horror" />
					<f:selectItem itemLabel=" Komedia" itemValue="Komedia" />
					<f:selectItem itemLabel=" Kryminał" itemValue="Kryminał" />
					<f:selectItem itemLabel=" Okruchy życia" itemValue="Okruchy zycia" />
					<f:selectItem itemLabel=" Przygodowa" itemValue="Przygodowa" />
					<f:selectItem itemLabel=" Satyra" itemValue="Satyra" />
					<f:selectItem itemLabel=" Parodia" itemValue="Parodia" />
					<f:selectItem itemLabel=" Romans" itemValue="Romans" />
					<f:selectItem itemLabel=" Science fiction"
						itemValue="Science fiction" />
					<f:selectItem itemLabel=" Sport" itemValue="Sport" />
					<f:selectItem itemLabel=" Militarystyka" itemValue="Militarystyka" />
					<f:selectItem itemLabel=" Literatura Faktu"
						itemValue="Literatura Faktu" />
					<f:selectItem itemLabel=" Literatura Naukowa" itemValue="Literatura Naukowa" />
				</h:selectManyCheckbox>

				
				<h:panelGroup>
				<h:commandButton value="Dodaj książke" action="#{bookBean.addBook}"  />
				</h:panelGroup>
			</h:panelGrid>
<script>
    setHighlight('${highlight}');
    setFocus('${focus}');
</script>
		</h:form>
 
	</ui:define>

</ui:composition>

</html>